<?php echo $this->element('displayHeader'); ?>
<?php echo $ajax->form('Customer', 'post', array('update'=>'content', 'indicator' => 'indicator', 'url'=>array('controller'=>'its_customers','action'=>'save'))); ?>

<div class="toolbar">
    <div id="tLeft">
        <?php if ($mode == 'add') : ?>
            <?php echo $this->element('toolbar', array('buttons' => array('save', 'clear', 'back'))); ?>
        <?php else : // mode edit ?>
            <?php echo $this->element('toolbar', array('buttons' => array('save', 'add', array('refresh_view' => array('model' => 'Customer')),
                    array('delete' => array('model' => 'Customer', 'title' => 'name')), 'back', 'view_as_customer'))); ?>
        <?php endif; ?>
    </div>
    <div id="tRight"><?php echo $this->element('neighbors', array('model' => 'Customer', 'title' => 'name')); ?></div>
</div>

<?php echo $form->input('Customer.id'); ?>
<fieldset>
    <legend>General Information</legend>
    <table>
        <?php if ($mode == 'edit') : ?>
        <tr>
            <td><?php echo $form->label('Customer.cust_no', 'No.', array('class' => 'required')); ?></td>
            <td>
                    <?php echo $html->tag('span', $this->data['Customer']['cust_no']); ?>
                    <?php echo $form->hidden('Customer.cust_no'); ?>
            </td>
        </tr>
        <?php endif; ?>
        <tr>
            <td><?php echo $form->label('Customer.short_name', 'Short Name'); ?></td>
            <td><?php echo $form->text('Customer.short_name', array('size' => '50')); ?></td>
        </tr>
        <tr>
            <td width="180px"><?php echo $form->label('Customer.name', 'Name', array('class' => 'required')); ?></td>
            <td><?php echo $form->text('Customer.name', array('size' => '50')); ?></td>
        </tr>
        <tr>
            <td><?php echo $form->label('Customer.response_email', 'ITS Response Email'); ?></td>
            <td>
                <?php echo $form->text('Customer.response_email', array('size' => '30')); ?>
                <span class="caption">(Separate with comma for multiple e-mail Ex. "abc@example.com, def@example.com)</span>
            </td>
        </tr>
        <tr>
            <td><?php echo $form->label('Customer.email', 'Customer Email'); ?></td>
            <td>
                <?php echo $form->text('Customer.email', array('size' => '30')); ?>
            </td>
        </tr>
    </table>
</fieldset>
<fieldset>
    <legend>Customer Address</legend>
    <table style="width: 600px">
        <tbody>
            <tr>
                <td class="top"><?php echo $form->label("Customer.contract", 'Contract') ?></td>
                <td colspan="3"><?php echo $form->text('Customer.contract', array('class' => 'wide')) ?></td>
            </tr>
            <tr>
                <td class="top"><?php echo $form->label("Customer.address", 'Address') ?></td>
                <td colspan="3"><?php echo $form->textarea('Customer.address', array('rows' => 2, 'cols' => 50, 'class' => 'wide')) ?></td>
            </tr>
            <tr>
                <td><?php echo $form->label("Customer.province_id", 'Province') ?></td>
                <td width="200px"><?php echo $form->select("Customer.province_id", $provinces) ?> </td>
                <td width="120px"><?php echo $form->label("Customer.zipcode", 'Zipcode') ?></td>
                <td><?php echo $form->text("Customer.zipcode", array('size'=>5,'maxlength'=>5)) ?></td>
            </tr>
            <tr>
                <td><?php echo $form->label("Customer.tel", 'Tel.') ?></td>
                <td><?php echo $form->text("Customer.tel") ?></td>
                <td><?php echo $form->label("Customer.fax", 'Fax') ?></td>
                <td><?php echo $form->text("Customer.fax") ?></td>
            </tr>
        </tbody>
    </table>
</fieldset>
<fieldset>
    <legend>User Privileges</legend>
    <table>
        <tr>
            <td width="120px"><?php echo $form->label('Customer.have_head_user', 'Head Office'); ?></td>
            <td width="150px">
                <?php echo $form->checkbox('Customer.have_head_user'); ?> Yes/No
            </td>
            <td width="200px"><?php echo $form->label('Customer.see_price_adjustment', 'See Price Adjustment'); ?></td>
            <td>
                <?php echo $form->checkbox('Customer.see_price_adjustment'); ?> Yes/No
            </td>
        </tr>
        <tr>
            <td><?php echo $form->label('Customer.can_view_other_site', 'View Other Sites'); ?></td>
            <td>
                <?php echo $form->checkbox('Customer.can_view_other_site'); ?> Yes/No
            </td>
            <td><?php echo $form->label('Customer.see_stock_in_current_stock', 'See current stock when stock in'); ?></td>
            <td>
                <?php echo $form->checkbox('Customer.see_stock_in_current_stock'); ?> Yes/No
            </td>
        </tr>
    </table>
</fieldset>
<?php echo $form->end(); ?>

<?php if ($mode == 'edit') : ?>
    <?php echo $this->requestAction('its_customers/display_sites/' . $this->data['Customer']['id'], array('return')); ?>
<?php endif; ?>
